// pages/components/counr-down/index.js
    Component({
        externalClasses: ['custom-class'], // 外部样式类
        properties: {
          time: {
            type: Number,
            value: 60,
          }
        },
        lifetimes: {
          attached() {
            // 开始倒计时
            this.countStart()
          },
        },
        methods: {
          countStart() {
            let timer = null
            // 停止定时器
            if (this.data.time === 0) return clearTimeout(timer)
            // 更新渲染
            this.setData({
              time: (this.data.time -= 1),
            })
            // 定时器
            timer = setTimeout(this.countStart.bind(this), 1000)
            // 传递数据到组件外部
            this.triggerEvent('change', this.data.time)
          },
        },
      })